<template>
    <div class="Collection">
        <div class="coll-top">
            <van-icon name="arrow-left" @click="$router.go(-1)" />
            <span>我的收藏</span>
        </div>
        <div class="article">
            <div class="acticle-container" v-for="(item, i) in signal" :key="item._id">
                <p>{{ item.title }}</p>
                <div class="imgs">
                    <img :src="img" alt="" v-for="img in item.imageSrc" :key="img">
                </div>
                <div class="commentArea">
                    <span>{{ item.cate_name }}</span>
                    <span>{{ item.poster_type }}评论</span>
                    <span>{{ timer[i] }}</span>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
import { collect } from '../request/api/user.js'
import detailList from '../components/detail/detailList.vue'
import timer from '../utils/derevion.js'
export default {
    name: 'Collection',
    data() {
        return {
            signal: [],
            timer: [], // 时间戳
        }
    },
    components: {
        detailList
    },
    async mounted() {
        let res = await collect({
            user_id: localStorage.getItem('user_id'),
            skip: '0',
            limit: '20'
        })
        this.signal = res.data.data;
        this.timer = res.data.data.map(item => timer(item.time));
    }
}
</script>

<style lang="less" scoped>
.coll-top {
    width: 100%;
    height: 50px;
    background: rgb(7, 193, 96);
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #fff;

    span {
        margin-right: 50%;
        transform: translateX(50%);
    }
}

.article {
    width: 100%;

    .acticle-container {
        width: 100%;
        height: 200px;
        border-bottom: 1px solid #ccc;

        p {
            margin-left: 10px;
            height: 20px;
            overflow: hidden;
        }

        .imgs {
            width: 100px;
            height: 100px;
            display: flex;

            img {
                width: 100%;
                height: 100%;
                margin: 5px 10px;
            }
        }

        span {
            margin: 0 10px;
        }

        .commentArea {
            width: 100%;
            margin-top: 20px;
        }
    }
}
</style>